﻿@inject IJSRuntime JsRuntime
<Card style="height: 400px">
    <BodyTemplate>
        <button class="btn" type="button" @onclick="Delete">
            <span class="oi oi-trash text-danger"></span>
        </button>
        <a href="@ImageUrl" target="_blank">
            <img style="width: 100%; height: 340px; object-fit: contain;" src="@ImageUrl" alt="@ImageUrl" onerror="@Path.GetFileName(ImageUrl)" />
        </a>
    </BodyTemplate>
</Card>
@code {
    [Parameter]
    public string ImageUrl { get; set; }
    [Parameter]
    public EventCallback<string> DeleteImage { get; set; }
    async Task Delete()
    {
        var confirmResult = await JsRuntime.InvokeAsync<bool>("confirm", $"确定要删除图片【{Path.GetFileName(ImageUrl)}】吗？");
        if (confirmResult) await DeleteImage.InvokeAsync(ImageUrl);
    }
}
